import Dispatch, { DispatchCallback, DispatchCallbackBool } from "../Util/Dispatch";


export enum GameEvent {
    UnitInitComplete,//孵化并初始完成了一个单位
    UnitDestroy,//有单位销毁
    PlayerDestroy,//有单位销毁
    LogGameMessage,//在游戏界面上打印信息
    OnPlanetNoGravityInpact,//有星体被孤立（不被任何其他星球的引力影响）
    GameStart,
    GameReset,
    AudioClipEnded,
    TipGameMessage,//在左上角打印提示文本
    ECViewDataChangeToTip,//玩家的经济资源变动 弹tips
    FactoryConstructionFailed,//单位的工厂制造失败
    ActivateTechnology,//玩家激活科技
    EconomicComBroken,//击破经济能源系统！
    PlayerDataChange,//玩家数据变动
    UnitLevelUp,//等级提升
    UpdateLocalStorageValue,//更新本地键值对
    UnitEnterScreenField,//单位进入屏幕空间
    OnResetRewardAdTime,//广告冷却重置
    OnSecondTick,//每秒触发
    OnClickBackHome,//回到主页
    OnShareGame,
    OnTrackerDebug,//开启单位信息调试
    OnPlayerRelicGet,//玩家获取到遗物
    OnPlayerRelicActivate,//玩家激活遗物
    OnDrawLineByUICtrl,//绘制line
    OnDrawCircleByUICtrl,//绘制circle
}

export default class GameEventMgr {
    private static _dispatch: Dispatch = new Dispatch(false);

    static Register(target, event: GameEvent, callback: DispatchCallback | DispatchCallbackBool, widget: number = 0) {
        this._dispatch.on(target, event, callback, widget);
    }

    static UnRegister(target, event: GameEvent) {
        this._dispatch.off(target, event);
    }

    static Dispatch(event: GameEvent, ...args: any) {
        this._dispatch.emit(event, ...args);
    }
}